package com.zorn.platform.user.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import com.zorn.core.provider.ServiceSupportProvider;
import com.zorn.platform.user.service.IUserProfileService;
import com.zorn.platform.user.dao.UserProfileDao;

@Service
public class UserProfileService extends ServiceSupportProvider implements IUserProfileService {

	/* Fields
	================================================== */
	private UserProfileDao userProfileDao;
	
	@Override
	public String getProfile(int uid){
		return userProfileDao.getProfile(uid);
	}

	/* Methods
	================================================== */
	public List<Map<String, Object>> query(Map<String, Object> params) {
		List<Map<String, Object>> data = userProfileDao.query(params);

		return setQueryResult(isPaging() ? userProfileDao.count(params) : data.size(), data);
	}

	public int count(Map<String, Object> params) {
		return setCountResult(userProfileDao.count(params));
	}

	public String insert(Map<String, Object> params) {
		return setInsertResult(userProfileDao.insert(params), MapUtils.getString(params, "user_id"));
	}

	public int update(Map<String, Object> params) {
		return setUpdateResult(userProfileDao.update(params));
	}

	public int delete(Map<String, Object> params) {
		return setDeleteResult(userProfileDao.delete(params));
	}

	/* Getters & Setters
	================================================== */
	public void setUserProfileDao(UserProfileDao userProfileDao) {
		this.userProfileDao = userProfileDao;
	}

}